<?php
/**
 * 
 * 系统登录相关
 */
class LoginController extends Cola_Controller {
	
	/**
	 *
	 * 登录
	 */
    public function indexAction() {
    	
    	$model = $this->model('System');
		$this->loginUserInfo = $model->getLoginInfo();
		if( $this->loginUserInfo ){
			$this->redirect('/admin/index/index');
		}
    	
    	$error = '';
    	if( Cola_Request::isPost() ){
    		$username = trim($this->post('username'));
    		$password = trim($this->post('password'));
    		$loginRes = $model->login($username, $password);
    		if( $loginRes ){
    			$this->redirect('/admin/index/index');
    		}else{
    			$error = '用户名或密码错误';
    		}
    	}
    	$this->view->error = $error;
        $this->display();
    }

	/**
	 *
	 * 登出
	 */
    public function logoutAction() {
		 $model = $this->model('System');
    	 $loginRes = $model->loginOut();
    }

}
?>
